if(typeof QueScript=="undefined"){QueCore={};QueScript=(function(){
	//start of definition of CheckRule and Converter
	var CheckRule={
		STRING:function(x){return typeof x=="string"},
		NUMBER:function(x){return typeof x=="number"},
		BOOLEAN:function(x){return typeof x=="boolean"},
		IP:function(x){return typeof x=="string" && /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.extension(x)}
	};
	var Converter={
		toString:function(x){return ""+x},
		toLowerCase:function(x){return (""+x).toLowerCase()},
		toDayDiff:function(x){
			return parseInt((new Date()-x)/(24*60*60*1000))
		},
		toHourDiff:function(x){
			return parseInt((new Date()-x)/(60*60*1000))
		}
	};
	//end of definition of CheckRule and Converter
	function jsFilter(s){
		return s.replace(/\\/g,"\\").replace(/"/g,"\\\"").replace(/'/g,"\\\'")
	}
	//start of function for creating private properties
	function property(obj,name,e,predicate,converter){
		var value;
		obj[name]=function(e){
			if(typeof e=="undefined") return value;
			if(converter)e=converter(e);
			if(typeof predicate=="undefined") value=e;
			else if(predicate(e)) value=e;
			return obj
		};
		obj[name]["toJSON"]=function(){
			if(predicate==CheckRule.STRING) return "\""+jsFilter(value)+"\""
			else return value;
		};
		if (typeof e!="undefined") obj[name](e);
		return obj
	}
	//end of function for creating private properties
	
	var shell=WScript.createObject("Wscript.Shell"),
	_data={},
	fso=WScript.createObject("Scripting.FileSystemObject");
	QueCore=function(query){
		property(this,"all",{});
		this.Shell=shell;
		this.FSO=fso;
		this.init(query);
	};
	QueCore.prototype={
		init:function(query){
			return this
		},
		first:function(){
			return this.all()[0];
		},
		pause:function(str){
			var str=(typeof str=="undefined")?
				"PRESS ENTER TO CONTINUE..." : str
			WScript.stdOut.write(str);
			while(!WScript.StdIn.AtEndOfLine) WScript.StdIn.read(1);
			WScript.StdIn.readLine();
			return this
		},
		write:function(str){
			WScript.StdOut.write((str)?str:"");
			return this
		},
		writeln:function(str){
			WScript.StdOut.write((str)?str+"\n":"\n");
			return this
		},
		pwd:function(){
			return this.Shell.CurrentDirectory
		},
		each:function(collection, callback){
			if(typeof callback=="undefined"){
				var callback=collection;
				for(var i=0;i<this.all().length;i++){
					callback(i,this.all()[i]);
				}
			}else{
				var items=new Enumerator(collection),count=0;
				while (!items.atEnd()){
					callback(count++,items.item());
					items.moveNext()
				}
			}
			return this
		},
		query:function(qry){
			var qry=qry.split(/:\/\/|:\\\\/g),result=new QueCore();
			result.all(QueCore.protocol[qry[0]](qry[1]));
			return result;
		},
		data:function(i,e){
			if(typeof e==="undefined") return _data[i];
			else _data[i]=e;
			return this
		}
	};
	var r=new QueCore();
	r.Converter=Converter;
	r.CheckRule=CheckRule;
	r.addProperty=function(obj,name,checkRule,converter,value){
		obj[name]=function(s){
			return property(obj,name,s,r.CheckRule[checkRule],r.Converter[converter])
		};
		if(typeof obj["_privateVariables"]=="undefined"){
			obj["_privateVariables"]={};
		}
		obj["_privateVariables"][name]=name;
		if(typeof obj["toJSON"]=="undefined") {
			obj["toJSON"]=function(t){
				var tabs="",
				tabs2="",
				u=t||0;
				for(var i=0;i < u;i++)
					tabs+="\t";
				if(typeof t!="undefined") {
					tabs="\n"+tabs;
					tabs2=tabs+"\t";
				}
				var s="{";
				for(var n in this["_privateVariables"]){
					s+=tabs2+n+":"+this[n].toJSON()+","
				}
				return s.substr(0,s.length-1)+tabs+"}"
			}
		}
		obj[name](value);
		return r;
	};
	r.isReady=function(){
			return WScript.FullName.toLowerCase().indexOf("cscript.exe")>0
	};
	QueCore.protocol={};
	return r
})()}
(function(QueScript){
	QueScript.Http=function(){
		this.HT=WScript.CreateObject("Microsoft.XMLHTTP")
		QueScript.addProperty(this,"referer","STRING","toString","");
		QueScript.addProperty(this,"url","STRING","toString","");
	}
	QueScript.Http.prototype={
		className:function(){return "QueScript.Http"},
		open:function(s,t,u){
			try{
				this.url(t);
				this.HT.open(s,t,u);
			}catch(e){
				WScript.echo("Error in opening a connection to "+t);
			}
			return this
		},
		send:function(s){
			try{
				this.HT.send(s);return this
			}catch(e){
				WScript.echo("Error in sending request");
			}
		},
		setRequestHeader:function(s,t){this.HT.setRequestHeader(s,t);return this},
		responseText:function(){
			if (this.readyState()==4)
				return this.HT.responseText;
			else return null
		},
		readyState:function(){
			this.updateReferer();
			return this.HT.readyState
		},
		updateReferer:function(){
			if (this.HT.readyState==4 && this.HT.status=="200")
				this.referer(this.url())
			return this
		},
		responseXML:function(){
			if (this.readyState()==4)
				return this.HT.responseXML;
			else return null
		},
		status:function(){
			if (this.readyState()==4)
				return this.HT.status;
			else return null
		},
		statusText:function(){
			if (this.readyState()==4)
				return ""+this.HT.statusText
			else return null
		},
		getResponseHeader:function(s){
			if (this.readyState()==4)
				return ""+this.HT.getResponseHeader(s);
			else return null
		},
		getAllResponseHeaders:function(){
			if (this.readyState()==4)
				return ""+this.HT.getAllResponseHeaders()
			else return null
		}
	};
	QueScript.XMLHTTP=new QueScript.Http();
})(QueScript);
(function(QueScript){
	Argument=function(){
		QueScript.addProperty(this,"length","STRING","toString",WScript.arguments.length);
		for(var i=0;i<this.length();i++)
			this[i]=WScript.arguments.item(i);
	};
	Argument.prototype={
		toString:function(){
			var _args="";
			for(var i=0;i<this.length();i++)
				_args+=" " +this[i];
			return _args
		},
		find:function(str){
			var str=""+str;
			for(var i=0;i<this.length();i++){
				if(str==this[i])
				return i
			}
			return -1
		},
		search:function(str){
			var str=""+str;
			for(var i=0;i<this.length();i++){
				if(this[i].indexOf(str)>-1)
				return i
			}
			return -1
		},
		startBy:function(str){
			var str=""+str;
			for(var i=0;i<this.length();i++){
				if(this[i].indexOf(str)==0)
					return i
			}
			return -1
		},
		startByRemove:function(str){
			var a=this.startBy(str);
			if(a>-1) {
				this.remove(a);
				return true
			} else return false
		},
		searchRemove:function(str){
			var a=this.search(str);
			if(a>-1) {
				this.remove(a);
				return true
			} else return false
		},
		findRemove:function(str){
			var a=this.find(str);
			if(a>-1) {
				this.remove(a);
				return true
			} else return false
		},
		remove:function(id){
			if(typeof id=="number" && id<this.length()){
				if(id!=this.length()-1){					
					for(var i=id;i<this.length()-1;i++)
						this[i]=this[i+1]
				}
				this[this.length()]=null;
				this.length(this.length()-1);
			}
		}
	};
	QueScript.Argument=new Argument();
	QueScript.check=function(){
		if(!this.isReady()){
			var oSh=WScript.CreateObject("WScript.Shell");
			oSh.Run('CScript.exe "' + WScript.ScriptFullName+'"'+(QueScript.Argument));
			WScript.quit();
		}
	};
	QueScript.check();
})(QueScript);
(function(QueScript){
	//start of definition of QueScript File
	//Required for file:// protocol
	var isDirty=true;
	QueScript.File=function(pattern,currentPath){
		if(typeof currentPath=="undefined" 
			&& typeof QueScript!="undefined")
			this.init(pattern,QueScript.pwd());
		else
			this.init(pattern,currentPath);
	};
	QueScript.File.prototype={
		className:function(){return "QueScript.File"},
		init:function(pattern,currentPath){
			QueScript
			.addProperty(this,"path","STRING","toString",currentPath)
			.addProperty(this,"extension","STRING","toString")
			.addProperty(this,"name","STRING","toString")
			.addProperty(this,"content","STRING","toString")
			this.breakPath(pattern,currentPath);
			isDirty=true;
		},
		checkMask:function(name,extension){
			return(this.maskedCompare(this.name(),name)
				&& this.maskedCompare(this.extension(),extension))
		},
		maskedCompare:function(x,mask){
			var x=""+x,mask=""+mask;
			for(var p1=0,p2=0;p2<mask.length;p2++){
				var maskbit0=mask.substr(p2,1).toLowerCase(),maskbit1="";
				if(maskbit0=="*"){
					if(p2<mask.length-1) {
						if(p1==x.length) 
							return false
						else {
							maskbit1=mask.substr(p2+1,1).toLowerCase();
							while(p1<x.length-1){
								if(x.substr(p1++,1).toLowerCase()==maskbit1) {
									p2++;
									break
								}
							}
						}
					} else return true
				}else if(maskbit0=="?"){
					if((++p1)+1==x.length) return true
				}else if(p1==x.length){
					return true
				}else if(x.substr(p1++,1).toLowerCase()!=maskbit0)
					return false;
				if(p1==x.length && p2==mask.length-1)
					return true
			}
			return false
		},
		filename:function(){
			return this.name()+"."+this.extension()
		},
		fullPath:function(){
			return this.path()+"\\"+this.filename()
		},
		breakPath:function(pattern,currentPath){
			var queFile={},
				_filename="",
				_fileparts=pattern.split("\\");
			if(_fileparts.length>1) {
				_filename=_fileparts[_fileparts.length-1];
				_fileparts[_fileparts.length-1]=null;
				var _path=_fileparts.join("\\");
				if(_path.length<3 || (_path.substr(1,1)!=":" && _path.substr(0,2)!="\\\\"))
					this.path(currentPath+"\\"+_path);
				else
					this.path(_path);
			} else {
				_filename=pattern;
			}
			if(_filename.length>0) {
				var _nameparts=_filename.split(".");
				if(_nameparts.length>1){
					this.extension(_nameparts[_nameparts.length-1]);
					_nameparts[_nameparts.length-1]=null;
					this.name(_nameparts.join(".").replace(/\.$/,""));
				}else
					this.name(_filename)
			}
			return this
		},
		save:function(FileUrl,sCode){
			if(typeof FileUrl=="string"){
				if(typeof sCode!="undefined")
					this.content(""+sCode);
				this.breakPath(FileUrl)
			}
			if(this.content()){
				var objStream,url=(this.fullPath().substr(0,2)=="\\\\")?"~temp.tmp":this.fullPath();
				try{
					objStream = WScript.CreateObject("ADODB.Stream");
					objStream.Charset="utf-8";
					objStream.open();
					objStream.position=objStream.size
					objStream.writeText=this.content();
					objStream.saveToFile(url,2)
					objStream.close();
					objStream=null;
					if(url!=this.fullPath() && QueScript.FSO)
						QueScript.FSO.CopyFile("~temp.tmp",this.fullPath());
				}catch(e){
					WScript.echo("Error in saving file:"+url);
				}
			}
			isDirty=false;
			return this
		},
		load:function(url){  
			if(typeof url=="string") this.breakPath(url);
			if(this.fullPath()){
				var objStream=WScript.CreateObject("ADODB.Stream");
				objStream.Charset="utf-8";
				objStream.Type=2
				objStream.mode=3
				objStream.open();
				try{
					objStream.loadfromfile(this.fullPath());
				}catch(e){
					qs.writeln("Error loading "+this.fullPath());
				}
				this.content(objStream.readText());
				objStream.Close();
				objStream=null
			}
			isDirty=false;
			return this
		}
	};
	//End of definition of QueScript File
})(QueScript);
(function(QueScript){
	QueScript.URL=function(url){
		this.className=function(){return "QueScript.URL"};
		QueScript.addProperty(this,"url","STRING","toString","http://"+url);
		this.XMLHTTP=QueScript.XMLHTTP;
		this.init();
	};
	QueScript.URL.prototype={
		init:function(){
			QueScript
			.addProperty(this,"isDirty","BOOLEAN")
			.addProperty(this,"content","STRING","toString")
			.addProperty(this,"contentText","STRING","toString");
			this.isDirty(true);
		},
		status:function(){return this.XMLHTTP.status()},
		get:function(){
			this.XMLHTTP
			.updateReferer()
			.open("GET",this.url(),false);
			if(this.XMLHTTP.referer()!="")
				this.XMLHTTP.setRequestHeader("Referer",this.XMLHTTP.referer())
			this.XMLHTTP.send();
			return this.isDirty(false).refresh()
		},
		refresh:function(){
			if(this.isDirty()) this.get();
			this.content(this.XMLHTTP.responseText())
			.contentText(this.content().replace(
				/<script[^>]*>([\S\s](?!<\/script>))*[\S\s]<\/script>|<style[^>]*>([\S\s](?!<\/style>))*[\S\s]<\/style>|<title>([\S\s](?!<\/title>))*[\S\s]<\/title>|<[^>]+>/ig,""
				).replace(/ /g," ").replace(/\\s+/g," ")
			);
			return this
		},
		post:function(params){
			this.XMLHTTP
			.updateReferer()
			.open("POST",this.url(),false)
			.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
			.setRequestHeader("Content-length", (""+params).length)
			.setRequestHeader("Connection", "close");
			if(this.XMLHTTP.referer()!="")
				this.XMLHTTP.setRequestHeader("Referer",this.XMLHTTP.referer());
			this.XMLHTTP.send(params);
			return this.isDirty(false).refresh()
		},
		replaceContent:function(r,f){
			return this.content(this.content().replace(r,f))
		},
		parseContentText:function(r,target){
			var arg,reg,t;
			if(r && typeof r.length=="number"){
				arg=r;
				t=target;
			}else {
				arg=arguments;
				t=this;
			}
			reg=arg[0];
			for(var i=1;i<arg.length;i++)
				if(typeof t[arg[i]]=="undefined")
					t[arg[i]]=[];
			this.contentText().replace(reg,function(){
				for(var i=1;i<arguments.length;i++)
					if(typeof arg[i]!="undefined")
						t[arg[i]].push(arguments[i]);
			});
			return this
		},
		writeContent:function(){
			QueScript.writeln(this.refresh().content());
			return this
		}
	};
	QueCore.prototype.url=function(e){
		if(typeof e==="undefined") this.first().url();
		else 
			if(this.first().url()!=e)
				this.first().isDirty(true).url(e)
		return this
	}
	QueCore.prototype.content=function(e){
		return this.first().writeContent()
	};
	QueCore.prototype.status=function(e){
		return this.first().status()
	};
	QueCore.prototype.get=function(){
		this.first().get();
		return this
	};
	QueCore.prototype.post=function(){
		this.first().post();
		return this
	};
	QueCore.prototype.replaceContent=function(r,f){
		this.each(function(i,v){
			i.replaceContent(r,f);
		});
		return this
	};
	QueCore.prototype.writeContent=function(){
		this.first().refresh().writeContent();
		return this
	};
	QueCore.prototype.contentText=function(){
		return this.first().refresh().contentText();
	};
	QueCore.prototype.writeContentText=function(){
		QueScript.writeln(this.first().refresh().contentText());
		return this
	};
	QueCore.prototype.parseContentText=function(){
		var arg=arguments;
		this.first().refresh().parseContentText(arg,this);
		return this
	};
	QueCore.prototype.writeArray=function(prop,index){
		QueScript.write(this[prop][index]);
		return this
	};
	QueCore.prototype.writeProperty=function(prop){
		QueScript.write(this[prop]());
		return this
	};
})(QueScript);
if(typeof QueCore.protocol!="undefined"){
	QueCore.protocol["winmgmts"]=function(qry){
		var list=[],
			qry=qry.split("?"),
			objService=GetObject("winmgmts:\\\\"+qry[0]),
			colItems=objService.ExecQuery(qry[1]),
			items=new Enumerator(colItems);
		while(!items.atEnd()){
			list.push(items.item());
			items.moveNext();
		}
		return list
	};
	QueCore.protocol["http"]=function(qry){
		var urlList=[];
		urlList.push(new QueScript.URL(qry));
		return urlList;
	};
	QueCore.protocol["file"]=function(qry){
		var qry=qry.split("?"),
			mask=qry[0],
			para=(typeof qry[1]=="string")?qry[1]:"",
			pattern=new QueScript.File(mask),
			objFolder = QueScript.FSO.GetFolder(pattern.path()),
			useHourDiff=false,
			hourDiff=0,
			useDayDiff=false,
			dayDiff=0,
			filelist;
			para.replace(/h<(\d+)/g,function(s,s1){
				useHourDiff=true;
				useDayDiff=false;
				hourDiff=parseInt(s1)
			}).replace(/d<(\d+)/g,function(s,s1){
				useHourDiff=false;
				useDayDiff=true;
				dayDiff=parseInt(s1)
			});
		filelist=[];
		QueScript.each(objFolder.files,function(i,v){
			var qFile=new QueScript.File(""+v,"");
			qFile.dateCreated=function(){return(v.DateCreated)};
			if(qFile.checkMask(pattern.name(),pattern.extension())){
				if((!useHourDiff && !useDayDiff) || (
					useHourDiff && QueScript.Converter.toHourDiff(
						qFile.dateCreated
					) < hourDiff)|| (
					useDayDiff && QueScript.Converter.toDayDiff(
						qFile.dateCreated
					) < dayDiff)
				) filelist.push(qFile);
			}
		});
		return filelist
	};
}
